<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="di" uri="http://displaytag.sf.net"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Temple</title>

<style type="text/css">
tr.even {
	background-color: #eee;
}

tr.odd {
	background-color: #ddd;
}
</style>

<script type="text/javascript"
	src="<c:url value='/static/js/jquery-1.3.2.min.js'/>"> </script>
<script>
$(document).ready(function() {
	var imagefileIndex = 0;
	$('#addFile').click(function() {
		imagefileIndex++;
		var trimg = $("<tr/>").attr('id','imgFile_'+imagefileIndex);
		var tdimg = $("<td/>").append('Upload photo');
		var inputimg = $("<input/>").attr({'type':'file','size':'60','name':'imageFiles['+imagefileIndex +']'});
		tdimg.append(inputimg);
		trimg.append(tdimg);
		$('#fileTable').append(trimg);
	});

	$('#removeFile').click(function() {
		$("#imgFile_"+imagefileIndex).remove();
		imagefileIndex--;
	});
	
});
</script>
</head>
<body>

	<%
String ctx = request.getContextPath()+"/temple/savetemple";
String editctx = request.getContextPath()+"/temple/edittemple";
%>


	<form:form id="templeForm" method="POST" modelAttribute="templedata"
		action="<%=ctx %>" enctype="multipart/form-data">
		<table align="center">

			<tr>
				<td>Name</td>
				<td>City</td>
				<td>Location</td>
				<td>History</td>
				<td>Summer Morning Time</td>
				<td>Summer Evening Time</td>
				<td>Winter Morning Time</td>
				<td>Winter Evening Time</td>
			</tr>
			<tr>
				<td><form:hidden path="id" /> <form:input path="name"
						size="15" /></td>

				<td><form:select path="city.cityId">
						<form:option value="0" label="Select" />
						<form:options items="${cities}" itemValue="cityId"
							itemLabel="cityName" />
					</form:select></td>
				<td><form:input path="location" size="15" /></td>
				<td><form:input path="history" size="15" /></td>
				<td><form:input path="timing.summerMorningTime" size="15" /></td>
				<td><form:input path="timing.summerEveningTime" size="15" /></td>
				<td><form:input path="timing.winterMorningTime" size="15" /></td>
				<td><form:input path="timing.winterEveningTime" size="15" /></td>
			</tr>
			<tr>
				<td colspan='8'>
					<table id="imagesTable">
						<tr>${tmplImg.mediaURI}
							<img src="C:\Amit Kumar160\Amit home projects\eclipse-jee-juno-win32\projectmedia\templemedia\35\Hydrangeas.jpg"/>
							<c:forEach items="${templedata.templeImages}" var="tmplImg">
								<td><img src="${tmplImg.mediaURI}" width="100" height="100"></img></td>
							</c:forEach>

						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td colspan='8'>
					<table id="fileTable">
						<tr>
							<td>Upload photo<input size='60' name="imageFiles[0]"
								type="file" /></td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td><input id="addFile" type="button" value="Add More Photos" /></td>
				<td><input id="removeFile" type="button" value="Remove Photos" /></td>
			</tr>
		</table>
		<input type="submit" value="Save Temple" />
	</form:form>



	<di:table name="${allTemples}" requestURI="" pagesize="10" uid="t"
		export="true"
		decorator="com.onlinemathuracrud.displaydecorator.TempleDecorator">
		<di:caption>Showing List of All Temples</di:caption>
		<di:column title="S.No.">${t_rowNum}</di:column>
		<di:column property="name" title="Temple Name" />
		<di:column property="city.cityName" title="Temple City" />
		<di:column property="location" title="Temple Location" />
		<di:column property="history" title="Temple History" />
		<di:column property="timing.summerMorningTime"
			title="Summer Morning Time" />
		<di:column property="timing.summerEveningTime"
			title="Summer Evening Time" />
		<di:column property="timing.winterMorningTime"
			title="Winter Morning Time" />
		<di:column property="timing.winterEveningTime"
			title="Winter Evening Time" />
		<di:column property="insertTime" format="{0,date,dd/MM/yyyy HH:mm:ss}"
			sortable="true" />
		<di:column property="updateTime" format="{0,date,dd/MM/yyyy HH:mm:ss}"
			sortable="true" />
		<di:column property="editUrl" title="Edit Temple" />
		<di:column property="deleteUrl" title="Delete Temple" />

		<di:setProperty name="paging.banner.placement" value="bottom" />
		<di:setProperty name="export.pdf" value="true" />
		<di:setProperty name="export.xml" value="false" />
	</di:table>



</body>
</html>